#include "SGNode.h"

//Constructor
SGNode::SGNode()
{
}

//Destructor
SGNode::~SGNode()
{
	//delete all the node
	/*for(list<SGNode*>::iterator i = _children.begin(); i != _children.end(); i++)
	{
		if (*i != 0)
		{
			delete *i;
			*i = 0;
		}
	}*/
}

void SGNode::preUpdate(){}
void SGNode::postUpdate(){}

void SGNode::addChild(SGNode* child)
{
	_children.push_back(child);
}

void SGNode::goThrough()
{
	preUpdate();
	doUpdate();
	for(list<SGNode*>::iterator it = _children.begin(); it != _children.end(); it++)
		(*it)->goThrough();

	postUpdate();
}

void SGNode::dirty()
{
	for(list<SGNode*>::iterator it = _children.begin(); it != _children.end(); it++)
		(*it)->dirty();
}

void SGNode::setName(const string& name)
{
	_name = name;
}